package chixing.day19.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

public class PoolTest {
    public static void main(String[] args) {
        /*
        * public ThreadPoolExecutor(int corePoolSize, 最小线程数
                              int maximumPoolSize,    最大线程数
                              long keepAliveTime,     最大空闲时间
                              TimeUnit unit,          时间单位
                              BlockingQueue<Runnable> workQueue)    任务队列  【餐厅客人排队，先排队的人先进入餐厅】
         * */
        ExecutorService executorService = Executors.newCachedThreadPool();
        //线程池中的线程数是固定的
        ExecutorService executorService1 = Executors.newFixedThreadPool(5);
        //适用于周期性\定时任务的线程池
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
        //线程池就是一个线程对象，task1，task2 线程顺序执行来的任务
        ExecutorService executorService2 = Executors.newSingleThreadExecutor();


    }
}
